<template>
	<view class="index">
		<view class="bf">
			<u-tabs :list="list" :current="current" :scrollable="true" lineWidth="40px" :lineColor="subColor"
				@change="tabChange"></u-tabs>
		</view>
		<view class="uni-container mt10">
			<uni-table ref="table" border stripe emptyText="暂无明细">
				<uni-tr>
					<uni-th align="center">提现金额</uni-th>
					<uni-th align="center">手续费</uni-th>
					<uni-th align="center">预计到账金额</uni-th>
					<uni-th align="center">提现状态</uni-th>
					<uni-th align="center">申请时间</uni-th>
					<uni-th align="center">操作</uni-th>
				</uni-tr>
				<uni-tr v-for="(row, i) in withlist" :key="i">
					<uni-td>{{ row.withdrawalMoney }}</uni-td>
					<uni-td>
						<view class="name">{{ row.serviceMoney }}</view>
					</uni-td>
					<uni-td align="center">{{ row.money }}</uni-td>
					<uni-td align="center">{{ row.stateFormat }}</uni-td>
					<uni-td align="center">{{ row.created_at }}</uni-td>
					<uni-td align="center">
						<text class="cf06 mr10" @click.stop="cancelWith(row)" v-if="row.state==0">取消提现</text>
					</uni-td>
				</uni-tr>
			</uni-table>
			<view class="uni-pagination-box"><uni-pagination show-icon :page-size="queryForm.pageSize"
					:current="queryForm.pageNo" :total="total" @change="change" /></view>
		</view>
		<!-- <view class="np f-c-c">
			<view class="iconfont icon-queshengtu cb" style="font-size: 90rpx;"></view>
			<view class="f12 cb mt20">暂无明细</view>
		</view> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				subColor: uni.getStorageSync('subject_color'),
				current: 0,
				list: [{
					name: '全部',
					value:'',
				}, {
					name: '提现中',
					value:'review',
				}, {
					name: '提现成功',
					value:'pass',
				}, {
					name: '提现拒绝',
					value:'reject',
				}, {
					name: '提现取消',
					value:'cancel',
				}, ],
				queryForm: {
					state: null,
					storeId: "",
					pageNo: 1,
					pageSize: 10,
				},
				total: 0,
				withlist: [],
			}
		},
		onLoad() {
			this.fetchData()
		},
		methods: {
			async fetchData() {
				const {
					data: {
						list,
						total,
						pageNo,
						pageSize
					}
				} = await this.beg.request({
					url: this.api.storeWithdrawal,
					data: this.queryForm,
				})
				this.withlist = list ? list : [];
				this.total = total;
				this.queryForm.pageNo = pageNo;
				this.queryForm.pageSize = pageSize;
			},
			change(e) {
				this.queryForm.pageNo = e.current;
				this.fetchData()
			},
			tabChange(item) {
				this.current = item.index
				this.queryForm.state = item.value
				this.fetchData()
			},
			cancelWith(row) {
				uni.showModal({
					title: '温馨提示',
					content: '确定取消提现吗',
					success: async (res) => {
						if (res.confirm) {
							let {
								msg
							} = await this.beg.request({
								url: `${this.api.withCancel}/${row.id}`,
								method: "POST",
							})
							this.fetchData()
							uni.$u.toast(msg)
						}
					}
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	/deep/.current-index-text {
		color: #FD8906 !important;
	}
</style>